package com.slavshik.utils {

	/**
	 * @author Alexander Slavshik <as.kvint@gmail.com>
	 * created 01.06.2010
	 */
	public function replaceStringValues(stringObj:Object, obj:Object):String{
		var str:String = String(stringObj);
		var r:RegExp = /%\w+%/g;
		var matches:Array = str.match(r);
		var propName:String;
		var replaceValue:String;
		for (var i:int = 0;i < matches.length;i++) {
			propName = String(matches[i]).substr(1, -2);
			if(obj.hasOwnProperty(propName)){
				replaceValue = obj[propName];
				str = str.replace(matches[i], replaceValue);
			}
		}
		return unescape(str);
	}
}
